aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/mass test client/Commands/TreeCommand.cs
blob: 60cf234edf59459a7a94219d43b90bda30dcd512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;

namespace libsecondlife.TestClient
{
    public class TreeCommand: Command
    {
        public TreeCommand(TestClient testClient)
		{
			Name = "tree";
			Description = "Rez a tree.";
		}

        public override string Execute(string[] args, LLUUID fromAgentID)
		{
		    if (args.Length == 1)
		    {
		        try
		        {
		            string treeName = args[0].Trim(new char[] { ' ' });
		            ObjectManager.Tree tree = (ObjectManager.Tree)Enum.Parse(typeof(ObjectManager.Tree), treeName);

		            LLVector3 treePosition = new LLVector3(Client.Self.Position.X, Client.Self.Position.Y,
		                Client.Self.Position.Z);
		            treePosition.Z += 3.0f;

		            Client.Objects.AddTree(Client.Network.CurrentSim, new LLVector3(0.5f, 0.5f, 0.5f),
		                LLQuaternion.Identity, treePosition, tree, Client.GroupID, false);

		            return "Attempted to rez a " + treeName + " tree";
		        }
		        catch (Exception)
		        {
		            return "Type !tree for usage";
		        }
		    }

		    string usage = "Usage: !tree [";
		    foreach (string value in Enum.GetNames(typeof(ObjectManager.Tree)))
		    {
		        usage += value + ",";
		    }
		    usage = usage.TrimEnd(new char[] { ',' });
		    usage += "]";
		    return usage;
		}
    }
}